from flask import Flask
from flask_restful import Resource,Api,fields,marshal_with

app = Flask(__name__)
api = Api(app)

class NewsView(Resource):
    resource_fields = {
        'code':fields.Integer,
        'msg':fields.String
    }
    @marshal_with(resource_fields)
    def get(self):
        return {'code':200,'msg':'访问成功'}

    @marshal_with(resource_fields)
    def post(self):
        return {'msg':'注册成功'}

api.add_resource(NewsView,'/news/')

if __name__ == '__main__':
    app.run(debug=True)